#include "gameObj.h"

namespace TGO
{
	/*
		Manner
	*/
	Step Manner::NextStep( int role_state, UINT& cnt ) 
	{
		switch ( role_state ) {
		case ROLE_STATE::ROLE_NORMAL:
			return NextStepNormal( cnt );
		default:
			string anim = mStepList[ mTracer ].mAnim;
			if ( anim == "WalkL" ) {
				anim = "StillL";
			} else if ( anim == "WalkR" ) {
				anim = "StillR";
			} else if ( anim == "WalkF" ) {
				anim = "StillF";
			} else if ( anim == "WalkB" ) {
				anim = "StillB";
			}
			return Step( 10, anim );
		}
	}

	void Manner::SetStepList( vector< Step > stepList ) 
	{
		mStepList = stepList;
	}

	Step Manner::NextStepNormal( UINT& cnt )
	{
		if ( cnt < mStepList[ mTracer ].mCnt ) {
			++cnt;
			return mStepList[ mTracer ];
		}
		cnt = 0;
		mTracer = NextTracer();
		return mStepList[ mTracer ];
	}
	
	int Manner::NextTracer()
	{
		return ( mTracer + 1 ) % mStepList.size();
	}

	/*
		Role
	*/
	Role::Role( D3DXVECTOR2 pos, UINT width, UINT height, float speed ):mPos( pos ),
																		mWidth( width ),
																		mHeight( height ),
																		mRoleState( ROLE_STATE::ROLE_NORMAL ),
																		mSpeed( speed )
	{

	}

	/*
		Monster
	*/

	void Monster::Update( float dt )
	{

	}

	/*
		NPC
	*/
	void NPC::Update( float dt ) 
	{
		if (! mTimeCounter.Flies( dt ) ) {
			return;
		}

		SetCurrentAnim( mManner.NextStep( GetRoleState(), mCounter ).mAnim );
		if ( GetCurrAnim() == "WalkL" ) {
			WalkL();
		} else if ( GetCurrAnim() == "WalkR" ) {
			WalkR();
		} else if ( GetCurrAnim() == "WalkF" ) {
			WalkF();
		} else if ( GetCurrAnim() == "WalkB" ) {
			WalkB();
		} else if ( GetCurrAnim() == "StillR" ) {

		} else if ( GetCurrAnim() == "StillL" ) {

		} else if ( GetCurrAnim() == "StillB" ) {

		} else if ( GetCurrAnim() == "StillF" ) {

		}
	}

	/*
		FriendRole
	*/
	void FriendRole::Update( float dt )
	{
		
	}

}